<?php
function redox_insert_user_colors() {

$custom_css = get_option('redox_custom_css');
$element_background = get_option('redox_element_background');
$element_border = get_option('redox_element_border');
$element_text = get_option('redox_element_text');
$post_alt_text = get_option('redox_post_alt_text');
$post_alt_background = get_option('redox_post_alt_background');

$tag_background = get_option('redox_tag_background');
$tag_text = get_option('redox_tag_text');
$tag_alt_background = get_option('redox_tag_alt_background');
$tag_alt_text = get_option('redox_tag_alt_text');
$link_text = get_option('redox_link_text');
$link_text_underline = get_option('redox_link_text_underline');
$background = get_option('redox_background_color');
$sidebar_background = get_option('redox_sidebar_background_color');
$sidebar_accent_alt = get_option('redox_sidebar_accent_alt_color');
$sidebar_accent = get_option('redox_sidebar_accent_color');
$header_background = get_option('redox_header_background_color');
$gallery_background = get_option('redox_gallery_background_color');
$header_accent = get_option('redox_header_accent_color');
$page_dropdown_border = get_option('redox_page_dropdown_border');
$blockquote_border = get_option('redox_blockquote_border');
$post_headings = get_option('redox_post_headings');
$highlight_text = get_option('redox_highlight_text');
$highlight_background = get_option('redox_highlight_background');
$general_accent_background = get_option('redox_general_accent_background');
$general_accent_text = get_option('redox_general_accent_text');
$meta_hover = get_option('redox_meta_hover');
$background_img = get_option('redox_background_img');

?>
                

	<style type="text/css">
		<?php
			if(!empty($header_background)) {
		?>
			#header {
				background-color: <?php echo $header_background; ?>;
			}

			#pages .menu-item .sub-menu {
				background-color: <?php echo $header_background; ?>;
			}

		<?php 
			}
		?>
		<?php
			if(!empty($gallery_background)) {
		?>

			.post .gallery {
				background-color: <?php echo $gallery_background; ?>;
			}

		<?php 
			}
		?>
		<?php
			if(!empty($post_alt_background)) {
		?>

			h3.alt.title {
				background-color: <?php echo $post_alt_background; ?>;
			}

			.post.type-chat  p:nth-child(odd) {
				background-color: <?php echo $post_alt_background; ?>;
			}

			.post .media {
				background-color: <?php echo $post_alt_background; ?>; 
			}

		<?php 
			}
		?>
		<?php
			if(!empty($post_alt_text)) {
		?>
			h3.alt.title {
				color: <?php echo $post_alt_text; ?>;
			}

			h3.alt a {
				color: <?php echo $post_alt_text; ?>;
			}

			.post.type-chat  p:nth-child(odd) {
				color: <?php echo $post_alt_text; ?>;
			}

			.post.type-chat  p:nth-child(odd) {
				background-color: <?php echo $post_alt_background; ?>;
			}
			
		<?php 
			}
		?>
		<?php
			if(!empty($header_accent)) {
		?>
			#header .author-preview-thumbnail img {
				border: 2px solid <?php echo $header_accent; ?>;
			}

			#pages ul, #pages li {
				color: <?php echo $header_accent; ?>;
			}

			#pages a {
				color: <?php echo $header_accent; ?>;
			}

			#pages .sub-menu .menu-item  {
				color: <?php echo $header_accent; ?>;
			}

			#header h1 a {
				color: <?php echo $header_accent; ?>;
			}

			#pages .menu-item a {
				color: <?php echo $header_accent; ?>;
			}

		<?php 
			}
		?>

		<?php
			if(!empty($sidebar_accent)) {
		?>

			.widget.post {
				color: <?php echo $sidebar_accent; ?>;
			}

			.widget_wrapper .widget.post a, .widget_wrapper .widget.post h3 {
				color: <?php echo $sidebar_accent; ?>;
			}

			.widget .tweet li:before {
				border-color: <?php echo $sidebar_accent; ?> transparent transparent <?php echo $sidebar_accent; ?>;
			}

			.widget .tweet li:nth-child(odd):before {
				border-color: <?php echo $sidebar_accent; ?>  <?php echo $sidebar_accent; ?> transparent   transparent ;
			}

			.widget.post .tweet li {
				background-color: <?php echo $sidebar_accent; ?>; 
			}

		<?php 
			}
		?>

		<?php
			if(!empty($sidebar_accent_alt)) {
		?>

			.widget.post .tweet li {
				color: <?php echo $sidebar_accent_alt; ?>;
			}

			.widget.post .tweet li a {
				color: <?php echo $sidebar_accent_alt; ?>;
			}

		<?php 
			}
		?>


		<?php
			if(!empty($page_dropdown_border)) {
		?>
			.minified-menu .minified-pages li ul li a {
				border-left: 4px solid <?php echo $page_dropdown_border; ?>;
			}

			#pages .sub-menu .menu-item  {
				border-left: 1px solid <?php echo $page_dropdown_border; ?>;
			}

			#pages .menu-item .sub-menu .menu-item .sub-menu .menu-item:first-child {
				border-right: 1px solid <?php echo $page_dropdown_border; ?>;
			}

			#pages .menu-item .sub-menu {
				border-top: 1px solid <?php echo $page_dropdown_border; ?>;
			}

			#pages .menu-item .sub-menu .menu-item {
				border-bottom: 1px solid <?php echo $page_dropdown_border; ?>;
			}

		<?php 
			}
		?>

		<?php
			if(!empty($sidebar_background)) {
		?>
			#header-expansion {
				background-color: <?php echo $sidebar_background; ?>;
			}
	
		<?php 
			}
		?>

		<?php
			if(!empty($background_img)) {
		?>
		body {
			background: fixed repeat top left url(<?php echo $background_img; ?>);
		}
		<?php
			}
		?>
		<?php
			if(!empty($element_text)) {
		?>
		body {
			color: <?php echo $element_text; ?>;
		}
		#header #pages .menu-item a, #header-image #pages .menu-item a {
			color: <?php echo $element_text; ?>;
		}
		#header #pages .menu-item, #header-image #pages .menu-item  {
			color: <?php echo $element_text; ?>;
		}
		#minified-header .mini-pages.drawer {
			color: <?php echo $element_text; ?>;
		}
		#minified-header .mini-pages a {
			color: <?php echo $element_text; ?>;
		}
		#pagination .page {
			color: <?php echo $element_text; ?>;
		}
		.post .meta .part {
			color: <?php echo $element_text; ?>;
		}
		.post .meta .part a {
			color: <?php echo $element_text; ?>;
		}
		.expansion .widget .widget-title a, .expansion .widget .widget-title {
			color: <?php echo $element_text; ?>;
		}
		#search-form #search {
			color: <?php echo $element_text; ?>;
		}
		.comment_form_meta .cf-meta a {
			color: <?php echo $element_text; ?>;
		}
		#search-form #search {
			color: <?php echo $element_text; ?>;
		}
		.comment-pagination-meta a {
			color: <?php echo $element_text; ?>;
		}
		#comment_body_form {
			color: <?php echo $element_text; ?>;
		}
		#submit, #reply-title, .comment-pagination-meta a {
			color: <?php echo $element_text; ?>;
		}
		#reply-title a {
			color: <?php echo $element_text; ?>;
		}
		.comment_form_meta .cf-meta input {
			color: <?php echo $element_text; ?>;
		}
		.type-comment .comment_meta .c-meta a {
			color: <?php echo $element_text; ?>;
		}
		#is-more {
			color: <?php echo $element_text; ?>;
		}
		#is-more a {
			color: <?php echo $element_text; ?>;
		}
		<?php
			}
		?>
		<?php
			if(!empty($element_border)) {
		?>
		#header .header.title {
			border-right: 1px solid <?php echo $element_border; ?>;
		}
		#header #pages .expansion-menu .menu-item  {
			border-right: 1px solid <?php echo $element_border; ?>;
		}
		#header #pages .menu-item, #header-image #pages .menu-item  {
			border-left: 1px solid <?php echo $element_border; ?>;
		}
		#header #pages .menu-item .sub-menu .menu-item .sub-menu .menu-item:first-child {
			border-right: 1px solid <?php echo $element_border; ?>;
		}
		#header #pages .menu-item .sub-menu, #header-image #pages .menu-item .sub-menu {
			border-top: 1px solid <?php echo $element_border; ?>;
		}
		#header-image #pages .menu-item .sub-menu .menu-item .sub-menu .menu-item:first-child {
			border-left: 1px solid <?php echo $element_border; ?>;
		}
		#header-wrap #pages .menu-item .sub-menu .menu-item {
			border-bottom: 1px solid <?php echo $element_border; ?>;
		}
		#minified-header .mini-pages.drawer {
			border-left:  1px solid <?php echo $element_border; ?>;
		}
		#minified-header .header.title {
			border-right:  1px solid <?php echo $element_border; ?>;
		}
		#pagination .page.left {
			border-right:  1px solid <?php echo $element_border; ?>;
		}
		#pagination .page.right {
			border-left: 1px solid  <?php echo $element_border; ?>;
		}
		#is-more .top {
			border-left:  1px solid <?php echo $element_border; ?>;
		}
		.entry table {
			border:  1px solid <?php echo $element_border; ?>;
		}
		.entry table td, .entry table th {
			border-top: 1px solid <php echo $element_border; ?>;
			border-left:1px solid  <?php echo $element_border; ?>;
		}
		.post .meta {
			border-top: 1px solid <?php echo $element_border; ?>;
		}
		.post .meta .part {
			border-right: 1px solid <?php echo $element_border; ?>;
		}
		.post .meta .part.back {
			border-left: 1px solid <?php echo $element_border; ?>;
		}
		#search-form #search {
			border: 1px solid <?php echo $element_border; ?>; 
		}
		.comment_form_meta {
			border-top: 1px solid <?php echo $element_border; ?>;
		}
		.comment_form_meta .cf-meta {
			border-left: 1px solid <?php echo $element_border; ?>;
		}
		.slider-controls.meta {
			border-top: 1px solid <?php echo $element_border; ?>;
		}
		.slider-controls.meta .part.right {
			border-left: 1px solid <?php echo $element_border; ?>;
		}
		.slider-controls.meta .part.left {
			border-right: 1px solid <?php echo $element_border; ?>;
		}
		<?php
			}
		?>
		<?php
			if(!empty($element_background)) {
		?>
		#header {
			background-color: <?php echo $element_background; ?>;
		}
		#header #pages .menu-item .sub-menu, #header-image #pages .menu-item .sub-menu {
			background-color: <?php echo $element_background; ?>;
		}
		#header-image #pages {
			background-color: <?php echo $element_background; ?>;
		}
		#minified-header {
			background-color: <?php echo $element_background; ?>;
		}
		#minified-pages {
			background-color: <?php echo $element_background; ?>;
		}
		#pagination {
			background-color: <?php echo $element_background; ?>;
		}
		#pagination .page {
			background-color: <?php echo $element_background; ?>;
		}
		#is-more {
			background-color: <?php echo $element_background; ?>;
		}
		.post {
			background-color: <?php echo $element_background; ?>;
		}
		.post .meta .share_menu {
			background-color: <?php echo $element_background; ?>;
		}
		.post .meta .part {
			background-color: <?php echo $element_background; ?>;
		}
		.type-comment {
			background-color: <?php echo $element_background; ?>;
		}
		#respond {
			background-color: <?php echo $element_background; ?>;
		}
		#submit, #reply-title, .comment-pagination-meta a {
			background-color: <?php echo $element_background; ?>;
		}
		.slider {
			background-color: <?php echo $element_background; ?>;
		}
		.slider-controls.meta {
			background-color: <?php echo $element_background; ?>;
		}
		<?php
			}
		?>
		<?php
			if(!empty($tag_background)) {
		?>
		.post .tags .tag {
			background-color: <?php echo $tag_background; ?>;
		}
		<?php
			}
		?>
		<?php
			if(!empty($tag_text)) {
		?>
		.post .tags a {
			color: <?php echo $tag_text; ?>;
		}
		<?php
			}
		?>
		<?php
			if(!empty($tag_alt_text)) {
		?>
		.post .tags .tag:hover a {
			color: <?php echo $tag_alt_text; ?>;
		}
		<?php
			}
		?>
		<?php
			if(!empty($tag_alt_background)) {
		?>
		.post .tags .tag:hover{
			background-color: <?php echo $tag_alt_background; ?>;
		}
		<?php
			}
		?>
		<?php
			if(!empty($link_text)) {
		?>
		a {
			color: <?php echo $link_text; ?>;
		}
		.post .entry a {
			color: <?php echo $link_text; ?>;
		}
		<?php
			}
		?>
		<?php
			if(!empty($link_text_underline)) {
		?>
		.post .entry a {
			border-bottom: 1px solid <?php echo $link_text_underline; ?>;
		}
		<?php
			}
		?>
		<?php
			if(!empty($background)) {
		?>
		body {
			background-color: <?php echo $background; ?>;
		}
		<?php
			}
		?>
		<?php
			if(!empty($blockquote_border)) {
		?>
		.post blockquote {
			border-left: 1px solid <?php echo $blockquote_border; ?>;   	
		}
		<?php
			}
		?>
		<?php
			if(!empty($post_headings)) {
		?>
		.post h1, .post h2, .post h3, .post h4, .post h5, .post h6 {
			color: <?php echo $post_headings; ?>; 
		}
		.post h1 a, .post h2 a, .post h3 a, .post h4 a, .post h5 a, .post h6 a {
			color: <?php echo $post_headings; ?>; 
		}
		<?php
			}
		?>
		<?php
			if(!empty($highlight_background)) {
		?>
		::selection {
			background: <?php echo $highlight_background; ?>; 
		}
		::-moz-selection {
			background: <?php echo $highlight_background; ?>; 
		}
		<?php
			}
		?>
		<?php
			if(!empty($highlight_text)) {
		?>
		::selection {
			color: <?php echo $highlight_text; ?>; 
		}
		::-moz-selection {
			color: <?php echo $highlight_text; ?>; 
		}
		<?php
			}
		?>

		
		<?php
			if(!empty($general_accent_text)) {
		?>
		pre {
			color: <?php echo $general_accent_text; ?>;
		}
		pre a {
			color: <?php echo $general_accent_text; ?>;
		}
		code {
			color: <?php echo $general_accent_text; ?>;
		}
		code a {
			color: <?php echo $general_accent_text; ?>;
		}
		<?php
			}
		?>
		<?php
			if(!empty($general_accent_background)) {
		?>
		pre {
			background-color: <?php echo $general_accent_background; ?>;
		}
		<?php
			}
		?>
		<?php
			if(!empty($meta_hover)) {
		?>
		.post .meta .part:hover, .post .meta .part:hover a {
			color: <?php echo $meta_hover; ?>;
		}
		<?php
			}
		?>
		<?php
            echo $custom_css;
		?>
	</style>
<?php
}
add_action( 'wp_head', 'redox_insert_user_colors' );
?>